package com.hadoop.sxtmr;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;


public class KeyPair implements WritableComparable<KeyPair>{
	private int year;
	private int hot;
	
	public int getYear() {
		return year;
	}
	public void setYear(int year) {
		this.year = year;
	}
	public int getHot() {
		return hot;
	}
	public void setHot(int hot) {
		this.hot = hot;
	}
	
	@Override
	public int compareTo(KeyPair o) {
		System.out.println("keypair.class");
		int res = Integer.compare(this.year, o.getYear());
		if (res != 0){
			return res;
		} else {
			return Integer.compare(hot, this.getHot());
		}
	}
	
	@Override
	public void write(DataOutput out) throws IOException {
		out.writeInt(year);
		out.writeInt(hot);
	}
	
	
	@Override
	public void readFields(DataInput in) throws IOException {
		this.year = in.readInt();
		this.hot = in.readInt();
		
	}
	@Override
	public int hashCode() {
		return new Integer(year+hot).hashCode();
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "{year " + year + " hot " + hot +"} " ;
	}
	
	
}
